package com.ittx.dzt.baiwang.factory;

import com.baiwang.open.client.BWRestClient;
import com.baiwang.open.client.IBWClient;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * sdk-client构建工厂
 * <p>
 *
 * </p>
 *
 * @author wl_code@163.com
 * @version 1.0
 * @date 2025/6/19
 */
public class BaiWangSdkClientFactory {

	private static ConcurrentMap<String, IBWClient> clients = new ConcurrentHashMap<>();

	/**
	 * 获取client对象
	 *
	 * @param appKey    appKey
	 * @param appSecret app密钥
	 * @param url       sdk地址
	 * @return client对象
	 */
	public static IBWClient getSdkClient(String url, String appKey, String appSecret) {
		if (clients.containsKey(appKey)) {
			return clients.get(appKey);
		}
		IBWClient client = new BWRestClient(url, appKey, appSecret); // 初始化一个客户端
		clients.put(appKey, client);
		return client;
	}

}
